package com.wbihua.common.metrics.metric;

import com.wbihua.common.metrics.type.EventTimerType;
import io.micrometer.core.instrument.Timer;

import java.time.Duration;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Supplier;

public interface EventMeterTimer extends EventMeter{
    EventTimerType getCounterType();

    void record(long amount, TimeUnit unit);

    void record(long amount, TimeUnit unit, String... tagValues);

    default void record(Duration duration) {
        record(duration.toNanos(), TimeUnit.NANOSECONDS);
    }

    default void record(Duration duration, String... tagValues) {
        record(duration.toNanos(), TimeUnit.NANOSECONDS, tagValues);
    }

    void record(Runnable f);

    void record(Runnable f, String... tagValues);

    void startTimer(Consumer<Timer.Sample> saveTimer, String... tagValues);

    void stopTimer(Supplier<Object> timerSupplier, String... tagValues);
}
